#include <vector>
#include <iostream>
#include <cstdio>

using namespace std;

/*
dp[i][j] : fill j with ith item, number of ith item left;

1. no need for i
dp[i-1][j] >= 0 

    dp[i][j] = cnt[i]

2. still impossible
dp[i-1][j] < 0 
    j < val[i] || dp[i][j-val] <= 0
    impossible  ||  used up

    dp[i][j] = -1

3. use i
dp[i-1][j] < 0
    j >= val[i] && dp[i][j-val] > 0

    dp[i][j] = dp[i][j-val] - 1

*/
int main()
{
    int N, V;
    const int MAX = 0x3f3f3f3f;
    while (scanf("%d%d", &N, &V) != EOF, V + N /*cin >> V >> N && N && V*/)
    {
        vector<int> val(N, 0);
        vector<int> cnt(N, 0);
        for (int i = 0; i < N; i++)
            cin >> val[i];
        for (int i = 0; i < N; i++)
            cin >> cnt[i];

        vector<int> dp(V + 1, -1);
        dp[0] = 0;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j <= V; j++)
            {
                if (dp[j] >= 0)
                    dp[j] = cnt[i];
                else if(j < val[i] || dp[j - val[i]] <= 0)
                    dp[j] = -1;
                else
                    dp[j] = dp[j - val[i]] - 1;
            }
        }
        int ans = 0;
        for (int i = 1; i <= V; i++)
            if (dp[i] >= 0)
                ans++;
        cout << ans << endl;
    }
    return 0;
}